import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isRightClickMenu: false,
    selectMenuTtem: {},
    rightMenu: [
      {
        name: '添加子菜单',
        method: '',
        param: "",
        isShow: true,
        children: []
      },
      {
        name: '添加兄弟菜单',
        method: '',
        param: "",
        isShow: true,
        children: []
      },
      {
        name: '删除',
        method: 'debounceItemDel',
        isShow: true,
        param: "",
      }
    ],
    rightMenuPosition: {
      x: 0, y: 0
    },
    pageFormConfig: {
      title: "",
      item: [],
      id: ""
    },
    objectNames: [],
    rightMenuData: {}, // 右键菜单
  },
  mutations: {

    // 右键菜单内容
    setRightMenu(state, value) {
      state.rightMenu = value
    },
    // 右键菜单位置
    setRightMenuPosition(state, value) {
      state.rightMenuPosition = value
    },
    // 添加右键菜单子菜单
    setRightMenuChild(state, menu) {

      state.rightMenu[0].children = menu.childDescriptors
      state.rightMenu[1].children = menu.siblingDescriptors
      state.rightMenu[2].param = menu.del
      state.rightMenu[0].isShow = menu.isChild
      state.rightMenu[1].isShow = menu.isSibling
      console.log('菜单存入到')
      console.log(state.rightMenu)
    },
    // 是否显示右键菜单
    setIsRightClickMenu(state, value) {
      state.isRightClickMenu = value
    },
    // 设置选中的右键菜单
    setSelectMenuTtem(state, value) {
      state.selectMenuTtem = value
    },
    // 设置 pageFormConfig
    setPageFormConfig(state, obj) {
      state.pageFormConfig = {
        title: obj.title || "",
        item: obj.item || [],
        id: obj.id || ""
      }
    },
    // 设置
    setObjectNames(state, value) {
      state.objectNames = value
    },
    // 设置右键菜单
    setRightMenuData(state, item) {
      state.rightMenuData[item.id] = item.data
    }
  },
  actions: {
  },
  modules: {
  }
})
